﻿namespace com.stifel.BranchMgmtDao
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public partial class StifelBranchUnit : IBranchRelated
    {
        #region Fields

        const string BR = "<br />";

        List<string> _CheckCodes;
        string _CheckCodesAsHtml;
        List<string> _DestinationCodes;
        string _DestinationCodesAsHtml;
        List<string> _WireCodes;
        string _WireCodesAsHtml;

        #endregion Fields

        #region Properties

        public List<string> CheckCodes
        {
            get
            {
                if ( _CheckCodes == null )
                {
                    _CheckCodes = new List<string>( );
                    if ( !string.IsNullOrEmpty( DestinationCheckCode ) )
                    {
                        _CheckCodes = DestinationCheckCode.Split( new string[ ] { ";" }, StringSplitOptions.RemoveEmptyEntries ).ToList( );
                        _CheckCodes.ForEach( a => a.Trim( ) );
                        _CheckCodes.Sort( );
                    }
                }
                return _CheckCodes;
            }
        }

        public string CheckCodesAsHtml
        {
            get
            {
                if ( string.IsNullOrEmpty( _CheckCodesAsHtml ) )
                {
                    StringBuilder sb = new StringBuilder( );
                    CheckCodes.ForEach( a => sb.AppendFormat( "{0}\t", a ) );
                    _CheckCodesAsHtml = sb.ToString( ).TrimEnd( '\t' ).Replace( "\t", BR );
                    sb = null;
                }
                return _CheckCodesAsHtml;
            }
        }

        public List<string> DestinationCodes
        {
            get
            {
                if ( _DestinationCodes == null )
                {
                    _DestinationCodes = new List<string>( );
                    if ( !string.IsNullOrEmpty( DestinationCode ) )
                    {
                        _DestinationCodes = DestinationCode.Split( new string[ ] { ";" }, StringSplitOptions.RemoveEmptyEntries ).ToList( );
                        _DestinationCodes.ForEach( a => a.Trim( ) );
                        _DestinationCodes.Sort( );
                    }
                }
                return _DestinationCodes;
            }
        }

        public string DestinationCodesAsHtml
        {
            get
            {
                if ( string.IsNullOrEmpty( _DestinationCodesAsHtml ) )
                {
                    StringBuilder sb = new StringBuilder( );
                    DestinationCodes.ForEach( a => sb.AppendFormat( "{0}\t", a ) );
                    _DestinationCodesAsHtml = sb.ToString( ).TrimEnd( '\t' ).Replace( "\t", BR );
                    sb = null;
                }
                return _DestinationCodesAsHtml;
            }
        }

        public List<string> WireCodes
        {
            get
            {
                if ( _WireCodes == null )
                {
                    _WireCodes = new List<string>( );
                    if ( !string.IsNullOrEmpty( DestinationWireCode ) )
                    {
                        _WireCodes = DestinationWireCode.Split( new string[ ] { ";" }, StringSplitOptions.RemoveEmptyEntries ).ToList( );
                        _WireCodes.ForEach( a => a.Trim( ) );
                        _WireCodes.Sort( );
                    }
                }
                return _WireCodes;
            }
        }

        public string WireCodesAsHtml
        {
            get
            {
                if ( string.IsNullOrEmpty( _WireCodesAsHtml ) )
                {
                    StringBuilder sb = new StringBuilder( );
                    WireCodes.ForEach( a => sb.AppendFormat( "{0}\t", a ) );
                    _WireCodesAsHtml = sb.ToString( ).TrimEnd( '\t' ).Replace( "\t", BR );
                    sb = null;
                }
                return _WireCodesAsHtml;
            }
        }

        #endregion Properties
    }
}